
import {reqgetbanner} from '../../request/api'
const initState={
    banner:[]
}

const types={
    CHANGE_BANNER:'MINE_CHANGEBANNER'
}

const reducer =(state=initState,action)=>{
        switch(action.type){
            case types.CHANGE_BANNER:
                return {
                    ...state,
                    banner:action.arr
                }
            default:
                return state
        }
}   

export const actions={
    changebanner:arr=>({type:types.CHANGE_BANNER,arr}),


    reqbanner:()=>(dispatch,getState)=>{
        reqgetbanner().then(res=>{
            dispatch(actions.changebanner(res.data.list))
        })
    }
}

//导出数据
export const getbanner=state=>state.mine.banner
export default reducer